import request from "@/utils/request.js";
/** 
 * 产品列表
*/
export function getPageProducts(data){
  return request({
    url:`/jy-business/products/getPageProducts`,
    method:'post',
    data,
    noCancelToken:true
  })
}

/**
 * 保存产品
 * @param {object} data
 */
export function saveProduct(data){
  return request({
    url:`/jy-business/products/save`,
    method:'post',
    data
  })
}

/**
 * 产品详情
 * @param {string} id - 产品id
 */
export function getProductDetail(id){
  return request({
    url:`/jy-business/products/selectProductDetail`,
    method:'get',
    params:{id}
  })
}

/** 
 * 商品管理-上下架
 * @param {object} data
 * @param {string} data.id - 产品id
 * @param {string} data.sourceType - 产品类型
 * @param {string} data.shelfStatus - 产品状态
*/
export function updateShelfStatus(data){
  return request({
    url:`/jy-business/products/management/shelf`,
    method:'post',
    data
  })
}

/** 
 * 商品管理-批量上下架
 * @param {object} data
 * @param {array} commodityList - 产品列表
 * @param {string} commodityList[].id - 产品id
 * @param {string} commodityList[].sourceType - 产品类型
 * @param {number} shelfStatus 1上架 2下架
*/
export function batchUpdateShelfStatus(data){
  return request({
    url:`/jy-business/products/management/batch/shelf`,
    method:'post',
    data
  })
}

/**
 * 是否小程序首页展示
 * @param {object} data
 * @param {string} data.id - 产品id
 * @param {string} data.showIndex - 产品类型
 */
export function updateShowIndex(data){
  return request({
    url:`/jy-business/products/show/index`,
    method:'post',
    data
  })
}